Skip to main content

Create AI Model

Used to create a new AI model with specified configuration. This allows you to integrate various AI models from different providers into your project.

API Endpoint

PropertyValue
Request MethodPOST
Request URLhttps://api.seliseblocks.com/models/

Request

Request Example

curl -X POST 'https://api.seliseblocks.com/models/' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"provider": "openai",
"service_platform": "official_api",
"version": "gpt-4",
"model_name": "gpt-4-turbo-preview",
"project_key": "YOUR_PROJECT_KEY",
"display_name": "GPT-4 Turbo",
"api_key": "sk-your-api-key-here",
"base_url": "https://api.openai.com/v1",
"MaxTokens": 8192,
"DefaultTemp": 0.7
}'

Request Headers

FieldTypeRequiredDescription
acceptstringYesAccepted response format. Use application/json
Content-Typeapplication/jsonYesData type, must be application/json.

Request Body

Request Body Schema

{
"provider": "openai",
"service_platform": "official_api",
"version": "string",
"model_name": "string",
"project_key": "string",
"display_name": "string",
"api_key": "string",
"base_url": "string",
"openai_organization_id": "string",
"openai_project_id": "string",
"api_version": "string",
"deployment_name": "string",
"custom_parameters": {
"additionalProp1": {}
},
"custom_headers": {
"additionalProp1": {}
},
"MaxTokens": 8192,
"DefaultTemp": 0.7
}

Request Body Parameters

FieldTypeRequiredDescription
providerstringYesAI model provider (e.g., "openai", "anthropic", "azure", "google").
service_platformstringYesService platform type (e.g., "official_api", "azure", "custom").
versionstringYesModel version identifier.
model_namestringYesSpecific model name (e.g., "gpt-4-turbo-preview", "claude-3-opus").
project_keystringYesThe project key for your project.
display_namestringYesHuman-readable display name for the model.
api_keystringYesAPI key for authentication with the provider.
base_urlstringNoBase URL for API requests (defaults to provider's standard URL).
openai_organization_idstringNoOpenAI organization ID (for OpenAI models only).
openai_project_idstringNoOpenAI project ID (for OpenAI models only).
api_versionstringNoAPI version (required for Azure OpenAI).
deployment_namestringNoDeployment name (required for Azure OpenAI).
custom_parametersobjectNoAdditional custom parameters for the model.
custom_headersobjectNoCustom HTTP headers for API requests.
MaxTokensintegerNoMaximum number of tokens the model can generate (default: 8192).
DefaultTempnumberNoDefault temperature for generation (default: 0.7, range: 0-2).
note

Provider-Specific Requirements

  • OpenAI: Requires api_key, optionally openai_organization_id and openai_project_id
  • Azure OpenAI: Requires api_key, base_url, api_version, and deployment_name
  • Anthropic: Requires api_key, model name like "claude-3-opus-20240229"
  • Google: Requires appropriate authentication credentials in api_key
  • Custom providers: May require base_url and custom_headers
tip

Best practices for model configuration:

  • Use descriptive display names to easily identify models
  • Store API keys securely and rotate them regularly
  • Set appropriate MaxTokens based on your use case and budget
  • Start with DefaultTemp of 0.7 and adjust based on output quality
  • Test model configuration after creation
  • Document model-specific parameters in custom_parameters
  • Use separate models for development and production

Temperature guidelines:

  • 0.0-0.3: More deterministic, factual responses
  • 0.4-0.7: Balanced creativity and consistency (recommended default)
  • 0.8-1.0: More creative and varied responses
  • 1.1-2.0: Highly creative, potentially less coherent

The system will:

  • Validate API credentials during creation
  • Test connectivity to the model provider
  • Store credentials securely (encrypted at rest)
  • Make the model available for AI agents immediately
  • Track model usage and costs

Response

Success Response (201 Created)

Returns an object containing the creation status.

{
"is_success": true,
"item_id": "model_123",
"detail": "AI model created successfully",
"error": {}
}

Response Fields

FieldTypeDescription
is_successbooleanIndicates whether the creation was successful.
item_idstringThe unique identifier of the created model.
detailstringSuccess or failure message with additional context.
errorobjectError details if the operation failed (empty if successful).

Error Response (422 Unprocessable Entity)

Returns validation error details when the request body is invalid.

{
"detail": [
{
"loc": [
"body",
"api_key"
],
"msg": "Invalid API key format or authentication failed",
"type": "value_error.authentication"
}
]
}

Error Response Fields

FieldTypeDescription
detailarrayArray of validation error objects.
locarrayLocation of the error in the request (e.g., body field).
msgstringHuman-readable error message.
typestringError type identifier.

Common Error Scenarios

Error TypeDescriptionResolution
Invalid API KeyAPI key is incorrect or expiredVerify API key from provider dashboard
Authentication FailedProvider rejected credentialsCheck API key permissions and quotas
Invalid Model NameModel name doesn't exist or is misspelledVerify model name with provider documentation
Missing Required FieldRequired provider-specific field missingAdd required fields (e.g., deployment_name for Azure)
Connection FailedCannot connect to provider's APICheck base_url and network connectivity
Quota ExceededProvider API quota exceededUpgrade plan or wait for quota reset

Error Codes

Status CodeDescriptionResponse Type
201Created - Model created successfullySuccess
400Bad Request - Invalid model configurationBad Request
401Unauthorized - Invalid API credentialsUnauthorized
409Conflict - Model with same name already existsConflict
422Validation Error - Invalid request parametersUnprocessable Entity
503Service Unavailable - Provider API unavailableService Unavailable